<?php
/* *
 * $Author ：PHPYUN开发团队
 *
 * 官网: http://www.phpyun.com
 *
 * 版权所有 2009-2018 宿迁鑫潮信息技术有限公司，并保留所有权利。
 *
 * 软件声明：未经授权前提下，不得用于商业运营、二次开发以及任何形式的再次发布。
 */
class pay_controller extends company{

	function index_action(){

		die('aaaa');
		
		$this->public_action();
		$statis=$this->company_satic();
		if($_GET['type']=='vip'){
			$rows=$this->obj->DB_select_all("company_rating","`service_price`<>'' and `display`='1' and `category`=1 order by sort desc","name,service_price,id");
			$this->yunset("rows",$rows);
		}
		$this->yunset("statis",$statis);
		$nopayorder=$this->obj->DB_select_num("company_job_order","`uid`=".$this->uid." and `order_state`=1");
		$this->yunset('nopayorder',$nopayorder);
		$this->yunset($this->MODEL('cache')->GetCache(array('integralclass')));
		$this->yunset("js_def",4);
		$this->com_tpl('pay');
	}

	function dingdan_action(){
		
 		if($_POST['price']){
			$this->cookie->SetCookie("delay", "", time() - 60);
			$company=$this->obj->DB_select_once("company","`uid`='".$this->uid."'","`name`,`hy`");
			
			if($company['name']==''||$company['hy']==''){
				$this->ACT_layer_msg("请先完善基本资料！",8,$this->config['sy_weburl']."/member/index.php?c=info");
			}
			if($_POST['price_int']){
				$integral=intval($_POST['price_int']);
				if($this->config['integral_min_recharge']&&$integral<$this->config['integral_min_recharge']){
					$integral=$this->config['integral_min_recharge'];
				}
				$integralid=intval($_POST['integralid']);
				
				$data['type']='1';
			}else {
				$this->ACT_layer_msg("参数不正确，请正确填写！",8,$_SERVER['HTTP_REFERER']);
			}
			if($data['type']=='2'&&$integral<1){
				$this->ACT_layer_msg("请正确填写购买数量！",8,$_SERVER['HTTP_REFERER']);
			}
	
			$price = $_POST['price'];
			$dingdan=mktime().rand(10000,99999);
			$data['type']='1';
			$data['order_id']=$dingdan;
			$data['order_dkjf']='0';
			$data['order_price']=$price;
			$data['order_time']=mktime();
			$data['order_state']="1";
			$data['order_type']=$_POST['paytype'];
			$data['order_remark']='赏金充值';
			$data['uid']=$this->uid;
			$data['integral']=$_POST['price_int'];

			$id=$this->obj->insert_into("company_job_order",$data);
				if($id){
					
					$this->obj->member_log("充值赏金,订单ID".$dingdan,88);
				
					
					$this->obj->DB_update_all("user_log","`status`='3',`orderid`='".$dingdan."'","`id`='".$_POST['logid']."'");
					
					$this->ACT_layer_msg("下单成功，请等管理员确认！",9,$this->config['sy_weburl']."/member/index.php?c=payment&id=".$id);
				}else{
					$this->obj->DB_update_all("user_log","`status`='2'","`id`='".$_POST['logid']."'");
					$this->ACT_layer_msg("提交失败，请重新提交订单！",8,$_SERVER['HTTP_REFERER']);
				}

		
		}else{

			$this->ACT_layer_msg("提交失败，请正确提交订单！",8,$_SERVER['HTTP_REFERER']);
		}
	}

	function dkzf_action(){
				
		$rows=$this->obj->DB_select_once("company","`uid`='".$this->uid."'");
		
		if(!$rows['name'] || !$rows['address'] || !$rows['pr']){
			echo json_encode(array('error'=>1,'msg'=>'请先完善企业资料！','url'=>$this->config['sy_weburl']."/member/index.php?c=info"));
 		}

		if($_POST){
   			$M=$this->MODEL('jfdk');
			if($_POST['tcid']){
				$return = $M->buyPackOrder($_POST);
			}elseif($_POST['id']){
				$return = $M->buyVip($_POST);				
			}
			if($return['status']==1){
				$this->obj->DB_update_all("user_log","`status`='1'","`id`='".$_POST['logid']."'");
				echo json_encode(array('error'=>0,'msg'=>$return['msg']));
			}else{
				$this->obj->DB_update_all("user_log","`status`='2'","`id`='".$_POST['logid']."'");
				echo json_encode(array('error'=>1,'msg'=>$return['error'],'url'=>$return['url']));
			}
		}else{
			echo json_encode(array('error'=>1,'msg'=>'参数错误，请重试！'));
		}
	}
 
}
?>